import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import directive from './directive'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/permission' // permission control
import drag from '@/utils/drag'
import '@/utils/rem'
import '@/icons' // icon
import 'default-passive-events'
import { Bus } from '@/utils/eventBus'
// 字典标签组件
import DictTag from '@/components/DictTag'
import Video from 'video.js'
import 'video.js/dist/video-js.css'
Vue.prototype.$video = Video

// 接收消息
const getsocketData = (e) => {
  const data = e && e.detail.data
  if (data !== '收到消息，消息内容：ping' && data !== '连接成功') {
    let newArr
    if (data && data.length > 0) {
      newArr = JSON.parse(data)
    } else {
      newArr = []
    }
    Bus.$emit('webSocket', newArr)
    console.log(newArr, 'datagetsocketData')
  }
}
// 注册监听事件
window.addEventListener('onmessageWS', getsocketData)
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from '@/utils/hbdr'
// 引入echarts
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.handleTree = handleTree
Vue.use(ElementUI)
Vue.use(directive)
// 全局组件挂载
Vue.component('DictTag', DictTag)
// 拖拽元素
Vue.use(drag)
Vue.config.productionTip = false
// 全局使用$Bus
Vue.prototype.$Bus = Bus
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
